Application Issues Labs
Demonstrate using
straceto determine what a process is doingDemonstrate how to use system monitoring tools and how they react to resource utilization
1. Using strace On Running Processes
On
server1.example.com, find the PID ofsshdlistener, and then usestraceto monitor connections to it, where-e acceptonly shows accept calls.# pgrep sshd|head -1 # strace -ff -e accept -p pid
From
desktop1.example.com, use SSH to connect toserver1.example.com.# ssh server1.example.com
Note what happens.
Press CTRL+c to exit
strace.Exit the SSH session.
2. Monitoring System Utilization with vmstat
On
desktop1.example.com, create the script/root/memoryHog.sh.#!/bin/bash delay=1s echo "begin allocating memory..." for index in $(seq 1000); do value=$(seq -w -s '' $index $(($index + 100000))) eval array$index=$value done echo "...end allocating memory" echo "sleeping for $delay" sleep $delayMake the script executable.
In a separate terminal or screen, start
vmstatto monitor the system every second.# vmstat -SM 1
Flush the disk cache from memory and note the
vmstatoutput change.# sync; echo 3 > /proc/sys/vm/drop_caches
Start
memoryHog.shand note the output ofvmstat.# /root/memoryHog.sh
Press CTRL+c to stop
memoryHogand notevmstatchanges.Don’t let it eat up the entire system memory or you will see the kernel invoke OOM Killer. Stop
vmstatwith CTRL+c.
3. Monitoring Processes with top
On
desktop1.example.com, in one terminal, start thetopcommand.In another terminal, start the
memoryHogcommand again and note howtopresponds.# /root/memoryHog.sh
Press CTRL+c to stop
memoryHogand note changes intop.Press CTRL+c to stop
top.
4. Monitoring Memory with free
On
desktop1.example.com, in one terminal, watch free memory in real time with thefreeandwatchcommands.# watch free -m
In another terminal, flush the cache and note changes in the
freeoutput.# sync; echo 3 > /proc/sys/vm/drop_caches
Start the
memoryHogcommand again and note how memory responds.# /root/memoryHog.sh
Press CTRL+c to stop
memoryHogand note changes infree.Press CTRL+c to stop
free.
5. Monitoring Memory with sar
On
desktop1.example.com, in one terminal, watch memory statistics withsar.# sar -r 1
In another terminal, flush the cache and note the changes in
saroutput.# sync; echo 3 > /proc/sys/vm/drop_caches
Start the
memoryHogcommand again and note how memory responds.# /root/memoryHog.sh
Press CTRL+c to stop
memoryHogand note the changes insar.Press CTRL+c to stop
sar.
6. Monitoring CPU with sar
On
desktop1.example.com, in one terminal, watch CPU statistics withsar.# sar -u 1
On another terminal, start the
memoryHogcommand again and note how the CPU responds.# /root/memoryHog.sh
Press CTRL+c to stop
memoryHogand note the changes insar.Press CTRL+c to stop
sar.